<div id="content">
    <h3><a href="../index.php?p=home">Geoplaza</a><a href="index.php?p=home"> &rsaquo;&rsaquo; Onderwijs</a> &rsaquo;&rsaquo; Mijn profiel</h3>
    <div id="Profilehead">Profiel</div>

    <div id="profile">
        <?php
        require_once('../config/appvars.php');
        require_once('../config/config.php');

        // Make sure the user is logged in before going any further.
        if (!isset($_SESSION['user_id'])) {
            echo '<p>Please <a href="../index.php?p=home">log in</a> to access this page.</p>';
            exit();
        }

        // Connect to the database
        $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);

        // Grab the profile data from the database
        if (!isset($_GET['user_id'])) {
            $query = "SELECT instellingNaam, adres, postcode, woonplaats, provincie, telefoon, email
                FROM onderwijsinstelling WHERE onderwijs_id = '" . $_SESSION['user_id'] . "'";
        } else {
            $query = "SELECT instellingNaam, adres, postcode, woonplaats, provincie, telefoon, email
                FROM onderwijsinstelling WHERE onderwijs_id = '" . $_SESSION['user_id'] . "'";
        }
        
        $data = mysqli_query($dbc, $query);

        if (mysqli_num_rows($data) == 1) {
            // The user row was found so display the user data
            $row = mysqli_fetch_array($data);

            if (!empty($row['instellingNaam'])) {
                echo '<div id="Profilecontent"><b>' . $row['instellingNaam'] . '</b></div>';
            }
            echo '<fieldset class="info">
            <legend>Onderwijs informatie</legend> ';
            echo '<p class="titel">Instellingnaam:</p><p class="in">' . $row['instellingNaam'] . '</p>';
            echo '<p class="titel">Adres:</p><p class="in">' . $row['adres'] . '</p>';
            echo '<p class="titel">&nbsp; </p><p class="in">' . $row['postcode'] . '   ' . $row['woonplaats'] . '</p>';
            echo '<p class="titel">Provincie:</p><p class="in">' . $row['provincie'] . '</p>';
            echo '<p class="titel">Telefoon:</p><p class="in">0' . $row['telefoon'] . '</p>';
            echo '<p class="titel">Email:</p><p class="in">' . $row['email'] . '</p>';
            echo '</fieldset>';
        } // End of check for a single row of user results
        else {
            echo '<p class="error">There was a problem accessing your profile.</p>';
        }
        mysqli_close($dbc);
        ?>

    </div>
</div>